package com.four.service.impl;

import com.four.dao.IStudentDao;
import com.four.dao.impl.StudentDaoImpl;
import com.four.entity.Student;
import com.four.service.IStudentService;

/**
 * 学生的业务
 * @author HZM
 * @version 2023/2/23
 */
public class StudentServiceImpl implements IStudentService {

    private IStudentDao studentDao = new StudentDaoImpl();

    /**
     * 注册学生的业务
     * @param student
     * @return
     */
    @Override
    public int register(Student student) {

        //判断账号是否存在
        int result1 = studentDao.checkColumn("username", student.getUsername());
        if (result1 >= 1){
            return -1;
        }

        //注册学生
        return studentDao.insert(student);
    }
}
